﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模块.TemplateMethod
{
    // "AbstractClass"
    public abstract class AbstractClass
    {
        // abstract Methods ,模板方法
        abstract internal void SendEmail();
        abstract internal void Shipping();

        internal void InsertOrder()
        {
            Console.WriteLine("只插入订单,对于所有具体模板它都是一样的，所以不需要重写");
        }
        // The Template method
        public void OrderFinish()
        {
            Console.WriteLine("下面将生成一个订单，它可能来自不同的国家客户的单子");
            InsertOrder();
            SendEmail();
            Shipping();
        }
    }

    // "ConcreteClass"
    public class ChinaClass : AbstractClass
    {
        // Methods
        internal override void SendEmail()
        {
            Console.WriteLine("给中国人发订单的邮件");
        }

        internal override void Shipping()
        {
            Console.WriteLine("给中国人送货，以中国的习惯");
        }
    }
    public class USAClass : AbstractClass
    {
        // Methods
        internal override void SendEmail()
        {
            Console.WriteLine("send a order email for usa client");
        }

        internal override void Shipping()
        {
            Console.WriteLine("send shipping for usa client");
        }
    }
}
